<?php

/**
 * login actions.
 *
 * @package    bbs2
 * @subpackage login
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
 */
class loginActions extends sfActions
{
    /**
     * Executes index action
     *
     */
    public function executeIndex()
    {
        $this->mailaddress = $this->getRequestParameter('mailaddress');
        return sfView::SUCCESS;
    }
    public function executeSubmit()
    {
        $this->mailaddress = $this->getRequestParameter('mailaddress');
        $this->password = $this->getRequestParameter('password');
        if ($this->mailaddress != '' && $this->password != '') {
            //メールアドレスとパスワードを元にテーブルの
            $c = new Criteria;
            $c->add(AdminPeer::MAILADDRESS, $this->mailaddress);
            $c->add(AdminPeer::PASSWORD, $this->password);
            $admin = AdminPeer::doSelectOne($c);

            print_r($admin);exit;
            if($admin) {

                // ログイン状態にする
                $this->getUser()->setAuthenticated(true);
                $this->getUser()->clearCredentials();
                $this->getUser()->addCredential('admin');

            }
            $this->redirect('/');

        }
        $this->forward("login","index");
    }
}
